home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: undergrad.math.uwaterloo.ca!clgonsal
- From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
- Subject: Re: Why don't you use garbage collection
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <DprnAs.C0@undergrad.math.uwaterloo.ca>
- Date: Fri, 12 Apr 1996 20:23:16 GMT
- References: <4kiai0$mjd@dfw-ixnews8.ix.netcom.com> <316D291F.465D@sto.fdata.se>
- Nntp-Posting-Host: lhopital.uwaterloo.ca
- Organization: University of Waterloo
-
- In article <316D291F.465D@sto.fdata.se>,
- Niklas Mellin <niklas.mellin@sto.fdata.se> wrote:
- >Giuliano Carlini wrote:
- >> In my experience, most C/C++ programmers either don't know what garbage
- >> collection is, or don't know that it can be used with C/C++. After all,
- >> no major C/C++ compiler includes a garbage collector. At least, as far
- >> as I know. I hope I'm wrong, and that someone can correct me. But even
- >> after, I tell them what it is, and that it can be used with C++, almost
- >> everyone still rejects it.
- >
- >No major C/C++ compiler includes a garbage collector, because it is not a
- >part of the C++ language. If you want a garbage collector you should go out
- >looking for a class library that implements it, not for a compiler. A C++
- >compiler that do garbage collection when you forget delete wouldn't be a
- >C++ compiler.
-
- There is nothing in the C++ language definition that says an implementation
- cannot use garbage collection. There was some talk in at least one of the
- books by Bjarne about GC. I seem to remember something to the effect of GC
- could exist in an implementation, but there are a few restrictions. For one
- thing, the destructor of a collected object never gets called. The
- rationale is that GC is a simulation of infinite memory, and so collected
- objects can't do anything when they get collected, since in an infinite
- memory system these objects aren't deleted. This means, with such a
- compiler, you'd probably want some other way of "finalizing" objects. This
- would probably have to be handled by a compiler extension.
-
- --
- Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
- Computer Science, University of Waterloo
- http://www.undergrad.math.uwaterloo.ca/~clgonsal/
- http://www.csclub.uwaterloo.ca/~clgonsal/
-